package com.ruoyi.web.controller.orderReservation;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.OrderReservation;
import com.ruoyi.system.service.IOrderReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 订单-预约关联Controller
 * 
 * @author ruoyi
 * @date 2025-06-03
 */
@RestController
@RequestMapping("/orderReservation/orderReservation")
public class OrderReservationController extends BaseController
{
    @Autowired
    private IOrderReservationService orderReservationService;

    /**
     * 查询订单-预约关联列表
     */
    @PreAuthorize("@ss.hasPermi('orderReservation:reservation:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderReservation orderReservation)
    {
        startPage();
        List<OrderReservation> list = orderReservationService.selectOrderReservationList(orderReservation);
        return getDataTable(list);
    }

    /**
     * 导出订单-预约关联列表
     */
    @PreAuthorize("@ss.hasPermi('orderReservation:reservation:export')")
    @Log(title = "订单-预约关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderReservation orderReservation)
    {
        List<OrderReservation> list = orderReservationService.selectOrderReservationList(orderReservation);
        ExcelUtil<OrderReservation> util = new ExcelUtil<OrderReservation>(OrderReservation.class);
        util.exportExcel(response, list, "订单-预约关联数据");
    }

    /**
     * 获取订单-预约关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('orderReservation:reservation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(orderReservationService.selectOrderReservationById(id));
    }

    /**
     * 新增订单-预约关联
     */
    @PreAuthorize("@ss.hasPermi('orderReservation:reservation:add')")
    @Log(title = "订单-预约关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderReservation orderReservation)
    {
        return toAjax(orderReservationService.insertOrderReservation(orderReservation));
    }

    /**
     * 修改订单-预约关联
     */
    @PreAuthorize("@ss.hasPermi('orderReservation:reservation:edit')")
    @Log(title = "订单-预约关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderReservation orderReservation)
    {
        return toAjax(orderReservationService.updateOrderReservation(orderReservation));
    }

    /**
     * 删除订单-预约关联
     */
    @PreAuthorize("@ss.hasPermi('orderReservation:reservation:remove')")
    @Log(title = "订单-预约关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(orderReservationService.deleteOrderReservationByIds(ids));
    }
}
